<?php
namespace app\pc\controller;
use app\api\model\LoginModel;
use app\common\controller\Controller;
use app\common\utils\Redis;

// 
class Common extends Controller
{

    public function _initialize(){

    }


    // 获取当前登录用户 id
    protected function checkLoginUser($need_login = false, $session_id = null,$save_type=1)
    {

        if($save_type == 1)
        {
            //保存 在 session
            $info = $this->getLoginUserInSession();
        }

        if ($need_login && empty($info)) {
            to_json_encode(300, '请登录', array('status' => false));
        }
        
        return isset($info['user_id'])?$info['user_id']:false;
    }

    //微信公众号 获取 当前登录用户
    private function getLoginUserInSession()
    {
        return session('user');
    }

}
